package com.cy.myblog.service.impl;

import com.cy.myblog.dao.BaseDaoI;
import com.cy.myblog.model.TloginAddr;
import com.cy.myblog.service.LoginAddrServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2015/6/13.
 */
@Service("loginAddrService")
public class LoginAddrServiceImpl implements LoginAddrServiceI {

    private BaseDaoI<TloginAddr> baseDao;

    @Autowired
    public void setBaseDao(BaseDaoI<TloginAddr> baseDao) {
        this.baseDao = baseDao;
    }

    @Override
    public void save(TloginAddr address) {
        baseDao.save(address);
    }

    @Override
    public TloginAddr getByAddress(String address) {
        String hql = "from TloginAddr where address=:address";
        Map<String,Object> params = new HashMap<String,Object>();
        params.put("address",address);
        TloginAddr loginAddress = baseDao.getByHql(hql, params);
        if(loginAddress == null){
            return null;
        }
        return loginAddress;
    }

    @Override
    public void update(TloginAddr loginAddress) {
        baseDao.update(loginAddress);
    }
}
